package com.woniuxy.qimengteacher.service.impl;

import com.woniuxy.qimengteacher.bean.TeachStageBean;
import com.woniuxy.qimengteacher.mapper.TeachStageMapper;
import com.woniuxy.qimengteacher.service.TeachStageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TeachStage)表服务实现类
 *
 * @author makejava
 * @since 2020-08-25 19:43:42
 */
@Service("teachStageService")
public class TeachStageServiceImpl implements TeachStageService {
    @Resource
    private TeachStageMapper teachStageMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public TeachStageBean queryById(Integer id) {
        return this.teachStageMapper.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<TeachStageBean> queryAllByLimit(int offset, int limit) {
        return this.teachStageMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param teachStageBean 实例对象
     * @return 实例对象
     */
    @Override
    public TeachStageBean insert(TeachStageBean teachStage) {
        this.teachStageMapper.insert(teachStage);
        return teachStage;
    }

    /**
     * 修改数据
     *
     * @param teachStageBean 实例对象
     * @return 实例对象
     */
    @Override
    public TeachStageBean update(TeachStageBean teachStage) {
        this.teachStageMapper.update(teachStage);
        return this.queryById(teachStage.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.teachStageMapper.deleteById(id) > 0;
    }
}